package borge.web.teamspirit.client.page.team;

import borge.web.teamspirit.client.data.SerieStats;

import com.google.gwt.user.client.ui.FlexTable;

public class TableUtil {

	
	public static int fillSerieStats(FlexTable aTable, SerieStats aStats, int row){
		
		int column = 0;
    	
    	int matchesPlayed = aStats.iMatchesWon+aStats.iMatchesDraw+aStats.iMatchesLost;
    	aTable.setText(row, column++, "Matches played");
		aTable.setText(row++, column--, Integer.toString(matchesPlayed));
		
		int percent = (int)((double)aStats.iMatchesWon / (double)matchesPlayed);
		aTable.setText(row, column++, "Matches won");
		aTable.setText(row++, column--, Integer.toString(aStats.iMatchesWon) + " (" + percent + "%)");
		
		percent = (int)((double)aStats.iMatchesDraw / (double)matchesPlayed);
		aTable.setText(row, column++, "Matches draw");
		aTable.setText(row++, column--, Integer.toString(aStats.iMatchesDraw)  + " (" + percent + "%)");
		
		percent = (int)((double)aStats.iMatchesLost / (double)matchesPlayed);
		aTable.setText(row, column++, "Matches lost");
		aTable.setText(row++, column--, Integer.toString(aStats.iMatchesWon)  + " (" + percent + "%)");
    	
		aTable.setText(row, column++, "Goals made");
		aTable.setText(row++, column--, Integer.toString(aStats.iGoalsMade));
		
		aTable.setText(row, column++, "Opponent goals");
		aTable.setText(row++, column--, Integer.toString(aStats.iOppGoals));
		
		aTable.setText(row, column++, "Yellow cards");
		aTable.setText(row++, column--, Integer.toString(aStats.iYellowCards));
		
		aTable.setText(row, column++, "Red Cards");
		aTable.setText(row++, column--, Integer.toString(aStats.iRedCards));
		
		return row;
		
	}
	
	
}
